//
//  BVHomeHeaderCollectionViewCell.m
//  BVHomeScene
//
//  Created by 崔晋 on 2019/10/19.
//

#import "BVHomeHeaderCollectionViewCell.h"

@interface BVHomeHeaderCollectionViewCell ()

@property (weak, nonatomic) IBOutlet UIView *dateContentView;
@property (weak, nonatomic) IBOutlet UILabel *dateMonthL;
@property (weak, nonatomic) IBOutlet UILabel *dateDayL;
@property (weak, nonatomic) IBOutlet UILabel *todayL;

@end

@implementation BVHomeHeaderCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor whiteColor];
    self.todayL.adjustsFontSizeToFitWidth = YES;
    
}


+ (CGSize)itemSizeWithType:(BOOL)isSelected {
    CGSize size = CGSizeZero;
    if (isSelected) {
        size = CGSizeMake(60, 27);
    }else {
        size = CGSizeMake(13, 27);
    }
    return size;
}

- (void)configWithModel:(BVWorkoutModel *)model type:(BOOL)isSelected {
    self.dateContentView.hidden = YES;
    self.todayL.hidden = YES;
    
    if (isSelected) {
        self.todayL.hidden = NO;
        if (model.enterAt.dateType == BVHomeHeaderCollectionCellTypeToday) {
            self.todayL.text = @"今日";
        }else if (model.enterAt.dateType == BVHomeHeaderCollectionCellTypeYesterday) {
            self.todayL.text = @"昨日";
        }else {
            self.todayL.text = [NSString stringWithFormat:@"%02ld/%02ld", (long)model.enterAt.date.month, (long)model.enterAt.date.day];
        }
    }else {
        self.dateContentView.hidden = NO;
        if (model.enterAt.dateType == BVHomeHeaderCollectionCellTypeToday) {
            self.dateMonthL.text = @"今";
            self.dateDayL.text = @"日";
        }else if (model.enterAt.dateType == BVHomeHeaderCollectionCellTypeYesterday) {
            self.dateMonthL.text = @"昨";
            self.dateDayL.text = @"日";
        }else {
            self.dateMonthL.text = [NSString stringWithFormat:@"%02ld", (long)model.enterAt.date.month];
            self.dateDayL.text = [NSString stringWithFormat:@"%02ld", (long)model.enterAt.date.day];
        }
        
    }
}


@end
